package com.aaa.market.controller;


import com.aaa.market.pojo.entity.Advertise;
import com.aaa.market.pojo.vo.AdvertiseVo;
import com.aaa.market.service.AdvertiseService;

import com.gsj.common.pojo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-eighth
 * @description:
 * @author: 刘守霖
 * @create: 2021-07-24 15:37
 **/
@RestController
@RequestMapping("/market/advertise")
@Api(description = "广告管理")
public class AdvertiseController {
    @Autowired
    private AdvertiseService advertiseService;

    @PostMapping("initAdvertiseTable/{currentPage}/{pageSize}")
    @ApiOperation(value = "查询广告管理表",httpMethod = "POST")
    public R initQuestionTable(@PathVariable("currentPage")Integer currentPage,
                               @PathVariable("pageSize")Integer pageSize,
                               @RequestBody AdvertiseVo advertiseVo){
        return advertiseService.findAdvertiseByPage(currentPage,pageSize,advertiseVo);
    }

    //新增
    @PostMapping("addbyAdvertiseId")
    @ApiOperation(value = "新增广告管理表中数据",httpMethod="POST")
    public R addbyAdvertiseId(@RequestBody Advertise advertise){
        return advertiseService.insertAdvertise(advertise);
    }
    //删除
    @DeleteMapping("delAdvertise")
    @ApiOperation(value = "根据id删除广告管理表中数据",httpMethod="DELETE")
    public R delAdvertise(Integer id){
        return advertiseService.delAdvertise(id);
    }
    //修改
    @PostMapping("changeAdvertise")
    @ApiOperation(value = "修改广告管理表中数据",httpMethod="POST")
    public R changeAdvertise(@RequestBody Advertise advertise){
        return advertiseService.changeAdvertise(advertise);
    }
    @GetMapping("chaXun")
    @ApiOperation(value = "修改前将数据回显到表单",httpMethod="GET")
    public R chaXun(Integer id){
        return advertiseService.chaXun(id);
    }
    @PutMapping("changeStatus")
    @ApiOperation(value = "修改广告管理表中数据状态",httpMethod="PUT")
    public R changeStatus(Integer id,Integer status){
        return advertiseService.changeStatus(id,status);
    }

    @PostMapping("queryPic")
    public R queryPic(){
        return advertiseService.queryPic();
    }
}
